import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'  //类似引入axios.js

Vue.use(ElementUI);
Vue.config.productionTip = false

Vue.prototype.$axios = axios //把axios配置成全局的，所有的组件都可以使用

axios.interceptors.request.use(
  config =>{
    //给请求携带请求头，以后不需要重复写
    let token=localStorage.getItem("authorization")
    if(token){
      config.headers.authorization = token  //等于{headers:{'authorization':token}}
    }
    return config
  }
)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
